package com.rabbit.demo.listener;

import com.rabbit.demo.OrderInfo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MqListener {

//    @RabbitListener(queues = "q.go")
//    public void payListener(){
//        System.out.println("支付成功");
//    }

    @RabbitListener(queues = "q.go.dlx")
    public void dlxListener(Message message, Channel channel){
        System.out.println("支付失败，超时");
        String id = new String(message.getBody());
        OrderInfo orderInfo = OrderInfo.map.get(id);
        if(orderInfo.getStatus() == 0){
            orderInfo.setStatus(2);
        }
    }
}
